package taewanme.gae.bookmark.resource;

import java.awt.print.Book;
import java.util.Date;

import javax.swing.LookAndFeel;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import ch.qos.logback.classic.Logger;

import taewanme.gae.bookmark.model.BookMark;
import taewanme.gae.bookmark.service.BookmarkServiceImpl;

@Component
@Path("bookmark")
public class BookMarkResourceImpl {
	private org.slf4j.Logger logger = LoggerFactory.getLogger(BookMarkResourceImpl.class);
	
	@Autowired
	private BookmarkServiceImpl bookmarkService;
	

	@GET
	@Path("dummy")
	@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
	public BookMark test(){
		BookMark bookmark = new BookMark();
		bookmark.setTitle("dddddd");
		return bookmark;
	}
	
	@POST
	@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
	@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
	public BookMark addBookMark(BookMark bookMark
			//, @HeaderParam("owner") @DefaultValue("bbbbb@gmail.com") String email
			){
		bookmarkService.addBookMark(bookMark, "bbbbb@gmail.com");
		return bookmarkService.readBookMark(bookMark.getUrl());
	}
	
	@POST
	@Path("dummy")
	@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
	@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
	public BookMark loopBookMark(BookMark bookMark){
		logger.info(bookMark.toString());
		bookMark.setCreDate(new Date());
		return bookMark;
	}
	
	
}
